﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using Caliburn.Micro;

namespace Phone.Framework.CaliburnExtensions.Results
{
    public class ResultHelper
    {
        public static void ActionWithLoad(Action<IActionResult> action)
        {
            IList<IResult> list = new List<IResult>();
            list.Add(LoadingResult.Default());
            list.Add(new ActionResult(action));
            list.Add(new LoadedResult());
            Coroutine.BeginExecute(list.GetEnumerator());
        }

        public static IEnumerable<IResult> Action(Action<IActionResult> action)
        {
            IList<IResult> list = new List<IResult>();
            list.Add(LoadingResult.Default());
            list.Add(new ActionResult(action));
            list.Add(new LoadedResult());
            return list;
        }

        public static IEnumerable<IResult> AppButtonAction(Action<IActionResult> action)
        {
            IList<IResult> list = new List<IResult>();
            list.Add(new LoadingResult("处理中"));
            list.Add(new AppButtonResult());
            list.Add(new ActionResult(action));
            list.Add(new AppButtonResult());
            list.Add(new LoadedResult());
            return list;
        }

        public static IEnumerable<IResult> AppMenuItemAction(Action<IActionResult> action)
        {
            IList<IResult> list = new List<IResult>();
            list.Add(new AppMenuItemResult());
            list.Add(new ActionResult(action));
            list.Add(new AppMenuItemResult());
            return list;
        }

        public static IEnumerable<IResult> ClearAction(Action<IActionResult> action)
        {
            IList<IResult> list = new List<IResult>();
            list.Add(new LoadingResult("处理中"));
            list.Add(new AppButtonResult());
            list.Add(new ActionResult(action));
            list.Add(new LoadedResult());
            return list;
        }

        public static IEnumerable<IResult> ContextMenuAction(Action<IActionResult> action)
        {
            IList<IResult> list = new List<IResult>();
            list.Add(new LoadingResult("处理中"));
            list.Add(new ActionResult(action));
            list.Add(new LoadedResult());
            return list;
        }

        public static void Execute(IResult action)
        {
            IList<IResult> list = new List<IResult>();
            list.Add(action);
            Coroutine.BeginExecute(list.GetEnumerator());
        }
    }
}
